﻿#include "OperModelTreeEvent.h"
#include "OperGraphPreprocess.h"

#include "GUIFrame/MainWindow.h"
#include "GUIFrame/CentralWidget.h"
#include "GUIWidget/TreeItemTypes.h"
#include "GUIWidget/BrowserWidget.h"
#include "GUIWidget/WidgetBrowserTable.h"
#include "GUIWidget/GraphArea.h"
#include "GUIWidget/ControlPanel.h"
#include "GUIWidget/TreeWidgetModel.h"
#include "GUIWidget/BrowserTableHandlerSubsystemBeam.h"
#include "GUIWidget/BrowserTableHandlerSubsystemPlate.h"
#include "GUIWidget/BrowserTableHandlerSubsystemSinglyShell.h"
#include "GUIWidget/BrowserTableHandlerSubsystemDoublyShell.h"
#include "GUIWidget/BrowserTableHandlerSubsystemCavity.h"
#include "GUIWidget/BrowserTableHandlerSubsystemSemiInfiniteF.h"
#include "GUIWidget/BrowserTableHandlerJunctionPointSEA.h"
#include "GUIWidget/BrowserTableHandlerJunctionLineSEA.h"
#include "GUIWidget/BrowserTableHandlerJunctionAreaSEA.h"
#include "GUIWidget/BrowserTableHandlerLoadPointForcesMoments.h"
#include "GUIWidget/BrowserTableHandlerLoadHVACNoise.h"
#include "GUIWidget/BrowserTableHandlerLoadPowerBeam.h"
#include "GUIWidget/BrowserTableHandlerLoadPowerShell.h"
#include "GUIWidget/BrowserTableHandlerLoadPowerAcoustic.h"
#include "GUIWidget/BrowserTableHandlerLoadConstraintBeam.h"
#include "GUIWidget/BrowserTableHandlerLoadConstraintShell.h"
#include "GUIWidget/BrowserTableHandlerLoadConstraintAcoustic.h"
#include "GUIWidget/BrowserTableHandlerLoadMonopole.h"
#include "GUIWidget/BrowserTableHandlerSubsystemFEStructure.h"
#include "GUIWidget/BrowserTableHandlerSubsystemFEAcoustic.h"
#include "GUIWidget/BrowserTableHandlerFESensors.h"

#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Kernel/FITKAppFramework/FITKRunTimeSetting.h"
#include "FITK_Component/FITKAcousticsModel/FITKAbstractSEASubSys.h"
#include "FITK_Component/FITKAcousticsModel/FITKAcousticsDiscModel.h"
#include "FITK_Component/FITKAcousticsModel/FITKAcousticsSEAModel.h"
#include "FITK_Component/FITKAcousticsModel/FITKAcousticsFEModel.h"
#include "FITK_Component/FITKAcousticsModel/FITKAcousticsFEFace.h"
#include "FITK_Component/FITKAcousticsModel/FITKAbstractFESubSys.h"
#include "FITK_Component/FITKAcousticsModel/FITKAcousticsSensors.h"
#include "FITK_Component/FITKAcousticsModel/FITKSEAAbstractJunction.h"
#include "FITK_Component/FITKAcousticsModel/FITKAcousticsGeometryData.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsPhysics.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsLoadManager.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsAbstractLoad.h"

#include <QTreeWidgetItem>
#include <QDebug>

namespace GUIOper
{
    OperatorModelTreeEvent::OperatorModelTreeEvent()
    {
        _DiscModel = FITKAPP->getGlobalData()->getMeshData<Acoustics::FITKAcousticsDiscModel>();
        _physics = FITKAPP->getGlobalData()->getPhysicsData<Acoustics::FITKAcousticsPhysics>();
        if (_DiscModel == nullptr)return;
        _SEAModel = _DiscModel->getSEAModel();
        _FEModel = _DiscModel->getFEModel();
    }
    void OperatorModelTreeEvent::itemClicked(QTreeWidgetItem* item, int colum)
    {
        Q_UNUSED(item);
        Q_UNUSED(colum);
    }

    void OperatorModelTreeEvent::itemDouleClicked(QTreeWidgetItem* item, int colum)
    {
        Q_UNUSED(item);
        Q_UNUSED(colum);
        if (item == nullptr) return;
        this->switchWindow(1);
        //从数据结构中获取表单对象
        GUI::MainWindow* mw = dynamic_cast<GUI::MainWindow*>(FITKAPP->getGlobalData()->getMainWindow());
        GUI::BrowserWidget* bw = mw->getCentralWidget()->getGraphArea()->getCurrentWindow<GUI::BrowserWidget>();
        if (bw == nullptr) return;
        GUI::WidgetBrowserTable* browserTable = bw->getTable();

        GUI::BrowserTableAbstractHandler* handler = nullptr;
        GUI::ModelTreeItemsType itemType = (GUI::ModelTreeItemsType)item->type();
        switch (itemType)
        {
        //子系统
        case GUI::ModelTreeItemsType::MTSEABeam:
            handler = new GUI::BrowserTableHandlerSubsystemBeam(browserTable); break;
        case GUI::ModelTreeItemsType::MTSEAPlate:
            handler = new GUI::BrowserTableHandlerSubsystemPlate(browserTable); break;
        case GUI::ModelTreeItemsType::MTSEASingleCurPlate:
            handler = new GUI::BrowserTableHandlerSubsystemSinglyShell(browserTable); break;
        case GUI::ModelTreeItemsType::MTSEADoubleCurPlate:
            handler = new GUI::BrowserTableHandlerSubsystemDoublyShell(browserTable); break;
        case GUI::ModelTreeItemsType::MTSEAVocalCavity:
            handler = new GUI::BrowserTableHandlerSubsystemCavity(browserTable); break;
        case GUI::ModelTreeItemsType::MTSEASemiInfiniteFluids:
            handler = new GUI::BrowserTableHandlerSubsystemSemiInfiniteF(browserTable); break;
        case GUI::ModelTreeItemsType::MTFEStruct:
            handler = new GUI::BrowserTableHandlerSubsystemFEStructure(browserTable); break;
        case GUI::ModelTreeItemsType::MTFEAcoustics:
            handler = new GUI::BrowserTableHandlerSubsystemFEAcoustic(browserTable); break;
        case GUI::ModelTreeItemsType::MTSensor:
            handler = new GUI::BrowserTableHandlerFESensors(browserTable); break;

        //连接
        case GUI::ModelTreeItemsType::MTCPSEA:
            handler = new GUI::BrowserTableHandlerJunctionPointSEA(browserTable); break;
        case GUI::ModelTreeItemsType::MTCCSEA:
            handler = new GUI::BrowserTableHandlerJunctionLineSEA(browserTable); break;
        case GUI::ModelTreeItemsType::MTCSSEA:
            handler = new GUI::BrowserTableHandlerJunctionAreaSEA(browserTable); break;

        //载荷
        case GUI::ModelTreeItemsType::MTLForceMoment:
            handler = new GUI::BrowserTableHandlerLoadPointForcesMoments(browserTable); break;
        case GUI::ModelTreeItemsType::MTHVACNoise:
            handler = new GUI::BrowserTableHandlerLoadHVACNoise(browserTable); break;
        case GUI::ModelTreeItemsType::MTLPBeam:
            handler = new GUI::BrowserTableHandlerLoadPowerBeam(browserTable); break;
        case GUI::ModelTreeItemsType::MTLPShell:
            handler = new GUI::BrowserTableHandlerLoadPowerShell(browserTable); break;
        case GUI::ModelTreeItemsType::MTLPAcoustic:
            handler = new GUI::BrowserTableHandlerLoadPowerAcoustic(browserTable); break;
        case GUI::ModelTreeItemsType::MTLCBeam:
            handler = new GUI::BrowserTableHandlerLoadConstraintBeam(browserTable); break;
        case GUI::ModelTreeItemsType::MTLCShell:
            handler = new GUI::BrowserTableHandlerLoadConstraintShell(browserTable); break;
        case GUI::ModelTreeItemsType::MTLCAcoustic:
            handler = new GUI::BrowserTableHandlerLoadConstraintAcoustic(browserTable); break;
        case GUI::ModelTreeItemsType::Monopole:
            handler = new GUI::BrowserTableHandlerLoadMonopole(browserTable); break;
        default: break;
        }

        if (handler)
            browserTable->update(handler);

    }

    void OperatorModelTreeEvent::itemStateChanged(QTreeWidgetItem *item, bool state, int column)
    {
        if (item == nullptr) return;
        //前处理渲染操作器
        GUIOper::OperGraphPreprocess* toper = Core::FITKOperatorRepo::getInstance()->getOperatorT<GUIOper::OperGraphPreprocess>("GraphPreprocess");
        if (toper == nullptr)return;
        AppFrame::FITKRunTimeSetting* rtSettings = FITKAPP->getGlobalData()->getRunTimeSetting();
        if (rtSettings == nullptr)return;

        //根据节点类型区分
        GUI::ModelTreeItemsType type = (GUI::ModelTreeItemsType) item->type();
        
        switch (type)
        {
        // 前处理模型显示控制
        case  GUI::ModelTreeItemsType::MTImportCAD_FEModels:
            toper->setCADVisiblity(state);
            break;
        case  GUI::ModelTreeItemsType::MTGraphObjectNodes: 
            toper->setUsedDiscNodesVisibility(state); break;
        case  GUI::ModelTreeItemsType::MTUnusedNodes:
            toper->setUnusedDiscNodesVisibility(state); break;
        case  GUI::ModelTreeItemsType::MTNodeLabels:
            toper->setNodeLabelsVisibility(state); break;
        case  GUI::ModelTreeItemsType::MTGeometryRoot:
            toper->setGeometrysVisiblity(state); break;
        //几何点显示控制
        case  GUI::ModelTreeItemsType::MTGeoNodes:
            setGeoPointsVisibility(state);
            rtSettings->setValue("GeomVertsVisibility", state);
            toper->updateGeometrys(true, true);
            break;
        //几何线显示控制
        case GUI::ModelTreeItemsType::MTGeoCurve:
            setGeoEdgesVisibility(state);
            rtSettings->setValue("GeomEdgesVisibility", state);
            toper->updateGeometrys(true, true);
            break;
        //几何面显示控制
        case  GUI::ModelTreeItemsType::MTGeoSurface:
            setGeoFacesVisibility(state);
            rtSettings->setValue("GeomFacesVisibility", state);
            toper->updateGeometrys(true, true);
            break;
        case  GUI::ModelTreeItemsType::MTGeoSolid:
            toper->setGeoSolidsVisiblity(state); break;

        // SEA子系统显示控制
        case GUI::ModelTreeItemsType::MTSubSystemRoot: 
            setSubSystemRootVisibility(state);
            toper->setSubSystemsVisibility(state); 
            break;
        case GUI::ModelTreeItemsType::MTSSSEARoot:
            setSEARootVisibility(state);
            toper->setSEASubSystemsVisibility(state);
            break;
        case GUI::ModelTreeItemsType::MTSEABeam:
            setSEASubSystemsBeamVisibility(state);
            toper->setSEASubSystemsVisibility(Acoustics::FITKAbstractSEASubSys::SEABeam, state);
            break;
        case GUI::ModelTreeItemsType::MTSEAShell:
            setSEASubSystemsShellVisibility(state);
            toper->setSEASubSystemShellsVisibility(state);
            break;
        case GUI::ModelTreeItemsType::MTSEAPlate:
            setSEASubSystemsPlateVisibility(state);
            toper->setSEASubSystemsVisibility(Acoustics::FITKAbstractSEASubSys::SEAFlatPlate, state);
            break;
        case GUI::ModelTreeItemsType::MTSEASingleCurPlate:
            setSEASubSystemsSingleCurvaturePlateVisibility(state);
            toper->setSEASubSystemsVisibility(Acoustics::FITKAbstractSEASubSys::SEASinglyCurvedShell, state);
            break;
        case GUI::ModelTreeItemsType::MTSEADoubleCurPlate:
            setSEASubSystemsDoubleCurvaturePlateVisibility(state);
            toper->setSEASubSystemsVisibility(Acoustics::FITKAbstractSEASubSys::SEADoublyCurvedShell, state);
            break;
        case GUI::ModelTreeItemsType::MTSEAVocalCavity:
            setSEASubSystemsVocalCavityPlateVisibility(state);
            toper->setSEASubSystemsVisibility(Acoustics::FITKAbstractSEASubSys::SEACavity, state);
            break;
        case GUI::ModelTreeItemsType::MTSEASemiInfiniteFluids:
            setSEASubSystemsSemiInfiniteFluidsVisibility(state);
            toper->setSEASubSystemsVisibility(Acoustics::FITKAbstractSEASubSys::SEASemiIInfiniteFluid, state);
            break;
        case GUI::ModelTreeItemsType::MTSSFERoot:
            setFERootVisibility(state);
            toper->setFESubSystemsVisibility(state); 
            break;
        case GUI::ModelTreeItemsType::MTFESurface:
            setFEFaceVisibility(state); 
            toper->setFEFaceVisibility(state);
            break;
        case GUI::ModelTreeItemsType::MTFEStruct:
            setFEStructVisibility(state);
            toper->setFEStructVisibility(state);
            break;
        case GUI::ModelTreeItemsType::MTFEAcoustics:
            setFEAcousticsVisibility(state);
            toper->setFEAcousticsVisibility(state);
            break;
        case GUI::ModelTreeItemsType::MTSensor:
            setSensorVisibility(state);
            toper->setSensorVisibility(state);
            break;

        // 连接关系显示控制
        case GUI::ModelTreeItemsType::MTConnectRoot:
            setConnectRootVisibility(state);
            toper->setJunctionsVisibility(state); 
            break;
        case GUI::ModelTreeItemsType::MTCPointRoot:
            setConnectPointVisibility(state);
            toper->setJunctionPointsVisibility(state);
            break;
        case GUI::ModelTreeItemsType::MTCPSEA:
            setConnectPointSEAVisibility(state);
            toper->setSEAJunctionPointsVisibility(state); 
            break;
        case GUI::ModelTreeItemsType::MTCPMix: break;
        case GUI::ModelTreeItemsType::MTCPFE: break;
        case GUI::ModelTreeItemsType::MTCCurveRoot:
            setConnectLineVisibility(state);
            toper->setJunctionLinesVisibility(state);
            break;
        case GUI::ModelTreeItemsType::MTCCSEA:
            setConnectLineSEAVisibility(state);
            toper->setSEAJunctionLinesVisibility(state);
            break;
        case GUI::ModelTreeItemsType::MTCCMix: break;
        case GUI::ModelTreeItemsType::MTCCFE: break;
        case GUI::ModelTreeItemsType::MTCSurfaceRoot:
            setConnectAreaVisibility(state);
            toper->setJunctionAreasVisibility(state); 
            break;
        case GUI::ModelTreeItemsType::MTCSSEA:
            setConnectAreaFEVisibility(state);
            toper->setSEAJunctionAreasVisibility(state);
            break;
        case GUI::ModelTreeItemsType::MTCSMix: break;
        case GUI::ModelTreeItemsType::MTCSFE: break;

        // 载荷显示控制
        case GUI::ModelTreeItemsType::MTLoadRoot:
            setLoadRootVisibility(state);
            toper->setLoadsVisibility(state); 
            break;
        case GUI::ModelTreeItemsType::MTLPower:
            setLoadPowerVisibility(state);
            toper->setLoadsPowerVisibility(state);
            break;
        case GUI::ModelTreeItemsType::MTLForceMoment:
            setLoadExcitationForceMomentsVisibility(state);
            toper->setLoadsPointForceVisibility(state); 
            break;
        case GUI::ModelTreeItemsType::MTLConstraint:
            setLoadConstraintVisibility(state);
            toper->setLoadsConstraintVisibility(state); 
            break;
        case GUI::ModelTreeItemsType::MTHVACNoise: 
            setLoadHVACNoiseVisibility(state);
            toper->setLoadsHVACNoiseVisibility(state);
            break;
        case GUI::ModelTreeItemsType::Monopole:
            setLoadMonopoleVisibility(state);
            toper->setLoadsHVACNoiseVisibility(state);
            break;
        default: break;
        }
        this->switchWindow(2);
    }

    void OperatorModelTreeEvent::updateModelTreeItemState()
    {
        GUI::MainWindow* mw = GUI::MainWindow::GetMainWindowFromFramework();
        if (mw == nullptr) return;
        GUI::CentralWidget* cw = mw->getCentralWidget();
        if (cw == nullptr) return;
        GUI::ControlPanel*  cp = cw->getControlPanel();
        if (cp == nullptr)return;
        GUI::TreeWidgetModel* modelTree = dynamic_cast<GUI::TreeWidgetModel*>(cp->getTreeWidget(GUI::TreeWidgetType::PageModel));
        if (modelTree == nullptr)return;
        modelTree->updateModelTreeItemState();
    }

    void OperatorModelTreeEvent::switchWindow(const int type)
    {
        GUI::MainWindow* mw = GUI::MainWindow::GetMainWindowFromFramework();
        if (mw == nullptr) return;
        GUI::CentralWidget* cw = mw->getCentralWidget();
        if (cw == nullptr) return;
        GUI::GraphArea* ga = cw->getGraphArea();
        if (ga == nullptr) return;
        ga->switch2AWindow((GUI::GraphAbstractSubWin::SubWinType)type);
    }

    void OperatorModelTreeEvent::setGeoPointsVisibility(bool state)
    {
        QList<Interface::FITKAbsVirtualTopo*> virTopos = getAllGeometryVirTopos(Interface::FITKGeoEnum::VTopoShapeType::VSPoint);
        for (Interface::FITKAbsVirtualTopo* virTopo : virTopos) {
            if (virTopo == nullptr) {
                continue;
            }
            virTopo->enable(state);
        }
    }

    void OperatorModelTreeEvent::setGeoEdgesVisibility(bool state)
    {
        QList<Interface::FITKAbsVirtualTopo*> virTopos = getAllGeometryVirTopos(Interface::FITKGeoEnum::VTopoShapeType::VSEdge);
        for (Interface::FITKAbsVirtualTopo* virTopo : virTopos) {
            if (virTopo == nullptr) {
                continue;
            }
            virTopo->enable(state);
        }
    }

    void OperatorModelTreeEvent::setGeoFacesVisibility(bool state)
    {
        QList<Interface::FITKAbsVirtualTopo*> virTopos = getAllGeometryVirTopos(Interface::FITKGeoEnum::VTopoShapeType::VSFace);
        for (Interface::FITKAbsVirtualTopo* virTopo : virTopos) {
            if (virTopo == nullptr) {
                continue;
            }
            virTopo->enable(state);
        }
    }

    void OperatorModelTreeEvent::setSubSystemRootVisibility(bool state)
    {
        setSEARootVisibility(state);
        setFERootVisibility(state);
        setSensorVisibility(state);
    }

    void OperatorModelTreeEvent::setSEARootVisibility(bool state)
    {
        setSEASubSystemsBeamVisibility(state);
        setSEASubSystemsShellVisibility(state);
        setSEASubSystemsVocalCavityPlateVisibility(state);
        setSEASubSystemsSemiInfiniteFluidsVisibility(state);
    }

    void OperatorModelTreeEvent::setFERootVisibility(bool state)
    {
        setFEFaceVisibility(state);
        setFEStructVisibility(state);
        setFEAcousticsVisibility(state);
    }

    void OperatorModelTreeEvent::setSEASubSystemsBeamVisibility(bool state)
    {
        if (_SEAModel == nullptr || _SEAModel->getSEASubSysManager() == nullptr)return;

        //修改数据显示隐藏状态
        for (Acoustics::FITKAbstractSEASubSys* subSys : _SEAModel->getSEASubSysManager()->
            getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEABeam)){
            if(subSys == nullptr)continue;
            subSys->enable(state);
        }
    }

    void OperatorModelTreeEvent::setSEASubSystemsShellVisibility(bool state)
    {
        setSEASubSystemsPlateVisibility(state);
        setSEASubSystemsSingleCurvaturePlateVisibility(state);
        setSEASubSystemsDoubleCurvaturePlateVisibility(state);
    }

    void OperatorModelTreeEvent::setSEASubSystemsPlateVisibility(bool state)
    {
        if (_SEAModel == nullptr || _SEAModel->getSEASubSysManager() == nullptr)return;

        //修改数据显示隐藏状态
        for (Acoustics::FITKAbstractSEASubSys* subSys : _SEAModel->getSEASubSysManager()->
            getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEAFlatPlate)) {
            if (subSys == nullptr)continue;
            subSys->enable(state);
        }
    }

    void OperatorModelTreeEvent::setSEASubSystemsSingleCurvaturePlateVisibility(bool state)
    {
        if (_SEAModel == nullptr || _SEAModel->getSEASubSysManager() == nullptr)return;

        //修改数据显示隐藏状态
        for (Acoustics::FITKAbstractSEASubSys* subSys : _SEAModel->getSEASubSysManager()->
            getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEASinglyCurvedShell)) {
            if (subSys == nullptr)continue;
            subSys->enable(state);
        }
    }

    void OperatorModelTreeEvent::setSEASubSystemsDoubleCurvaturePlateVisibility(bool state)
    {
        if (_SEAModel == nullptr || _SEAModel->getSEASubSysManager() == nullptr)return;

        //修改数据显示隐藏状态
        for (Acoustics::FITKAbstractSEASubSys* subSys : _SEAModel->getSEASubSysManager()->
            getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEADoublyCurvedShell)) {
            if (subSys == nullptr)continue;
            subSys->enable(state);
        }
    }

    void OperatorModelTreeEvent::setSEASubSystemsVocalCavityPlateVisibility(bool state)
    {
        if (_SEAModel == nullptr || _SEAModel->getSEASubSysManager() == nullptr)return;

        //修改数据显示隐藏状态
        for (Acoustics::FITKAbstractSEASubSys* subSys : _SEAModel->getSEASubSysManager()->
            getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEACavity)) {
            if (subSys == nullptr)continue;
            subSys->enable(state);
        }
    }

    void OperatorModelTreeEvent::setSEASubSystemsSemiInfiniteFluidsVisibility(bool state)
    {
        if (_SEAModel == nullptr || _SEAModel->getSEASubSysManager() == nullptr)return;

        //修改数据显示隐藏状态
        for (Acoustics::FITKAbstractSEASubSys* subSys : _SEAModel->getSEASubSysManager()->
            getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEASemiIInfiniteFluid)) {
            if (subSys == nullptr)continue;
            subSys->enable(state);
        }
    }

    void OperatorModelTreeEvent::setFEFaceVisibility(bool state)
    {
        if (_FEModel == nullptr || _FEModel->getFEFaceManager() == nullptr)return;

        //修改数据显示隐藏状态
        for (int index = 0; index < _FEModel->getFEFaceManager()->getDataCount(); index++){
            Acoustics::FITKAcousticsFEFace* face = _FEModel->getFEFaceManager()->getDataByIndex(index);
            if (face == nullptr)continue;
            face->enable(state);
        }
    }

    void OperatorModelTreeEvent::setFEStructVisibility(bool state)
    {
        if (_FEModel == nullptr || _FEModel->getFESubSysManager() == nullptr)return;

        //修改数据显示隐藏状态
        for (Acoustics::FITKAbstractFESubSys* subSys : _FEModel->getFESubSysManager()->
            getSubSysByType(Acoustics::FITKAbstractFESubSys::FESubSysType::FEStructure)) {
            if (subSys == nullptr)continue;
            subSys->enable(state);
        }
    }

    void OperatorModelTreeEvent::setFEAcousticsVisibility(bool state)
    {
        if (_FEModel == nullptr || _FEModel->getFESubSysManager() == nullptr)return;

        //修改数据显示隐藏状态
        for (Acoustics::FITKAbstractFESubSys* subSys : _FEModel->getFESubSysManager()->
            getSubSysByType(Acoustics::FITKAbstractFESubSys::FESubSysType::FEAcoustic)) {
            if (subSys == nullptr)continue;
            subSys->enable(state);
        }
    }

    void OperatorModelTreeEvent::setSensorVisibility(bool state)
    {
        if (_FEModel == nullptr || _FEModel->getSensorManager() == nullptr)return;

        //修改数据显示隐藏状态
        for (int index = 0; index < _FEModel->getSensorManager()->getDataCount(); index++) {
            Acoustics::FITKAcousticsSensors* sensor = _FEModel->getSensorManager()->getDataByIndex(index);
            if (sensor == nullptr)continue;
            sensor->enable(state);
        }
    }

    void OperatorModelTreeEvent::setConnectRootVisibility(bool state)
    {
        setConnectPointVisibility(state);
        setConnectLineVisibility(state);
        setConnectAreaVisibility(state);
    }

    void OperatorModelTreeEvent::setConnectPointVisibility(bool state)
    {
        setConnectPointSEAVisibility(state);
        setConnectPointFEVisibility(state);
    }

    void OperatorModelTreeEvent::setConnectLineVisibility(bool state)
    {
        setConnectLineSEAVisibility(state);
        setConnectLineFEVisibility(state);
    }

    void OperatorModelTreeEvent::setConnectAreaVisibility(bool state)
    {
        setConnectAreaSEAVisibility(state);
        setConnectAreaFEVisibility(state);
    }

    void OperatorModelTreeEvent::setConnectPointSEAVisibility(bool state)
    {
        if (_DiscModel == nullptr || _DiscModel->getJunctionManager() == nullptr)return;

        for (Acoustics::FITKAbstractJunction* jun : _DiscModel->getJunctionManager()->
            getJointsByType(Acoustics::FITKAbstractJunction::JunctionType::SEAPointJunction)){
            if (jun == nullptr)continue;
            jun->enable(state);
        }
    }

    void OperatorModelTreeEvent::setConnectPointFEVisibility(bool state)
    {

    }

    void OperatorModelTreeEvent::setConnectLineSEAVisibility(bool state)
    {
        if (_DiscModel == nullptr || _DiscModel->getJunctionManager() == nullptr)return;

        for (Acoustics::FITKAbstractJunction* jun : _DiscModel->getJunctionManager()->
            getJointsByType(Acoustics::FITKAbstractJunction::JunctionType::SEALineJunction)) {
            if (jun == nullptr)continue;
            jun->enable(state);
        }
    }

    void OperatorModelTreeEvent::setConnectLineFEVisibility(bool state)
    {

    }

    void OperatorModelTreeEvent::setConnectAreaSEAVisibility(bool state)
    {
        if (_DiscModel == nullptr || _DiscModel->getJunctionManager() == nullptr)return;

        for (Acoustics::FITKAbstractJunction* jun : _DiscModel->getJunctionManager()->
            getJointsByType(Acoustics::FITKAbstractJunction::JunctionType::SEAAreaJunction)) {
            if (jun == nullptr)continue;
            jun->enable(state);
        }
    }

    void OperatorModelTreeEvent::setConnectAreaFEVisibility(bool state)
    {

    }

    void OperatorModelTreeEvent::setLoadRootVisibility(bool state)
    {
        setLoadPowerVisibility(state);
        setLoadExcitationForceMomentsVisibility(state);
        setLoadConstraintVisibility(state);
        setLoadHVACNoiseVisibility(state);
    }

    void OperatorModelTreeEvent::setLoadPowerVisibility(bool state)
    {
        setLoadPowerBeamVisibility(state);
        setLoadPowerShellVisibility(state);
        setLoadPowerAcousticVisibility(state);
        setLoadPowerFESubSysVisibility(state);
    }

    void OperatorModelTreeEvent::setLoadExcitationForceMomentsVisibility(bool state)
    {
        if (_physics == nullptr || _physics->getFITKAcousticsLoadManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractLoad* load : _physics->getFITKAcousticsLoadManager()->
            getLoadByType(Acoustics::FITKAcousticsAbstractLoad::AcousticsLoadType::ExcitationForceMoments)) {
            if (load == nullptr)continue;
            load->enable(state);
        }
    }

    void OperatorModelTreeEvent::setLoadConstraintVisibility(bool state)
    {
        setLoadConstraintBeamVisibility(state);
        setLoadConstraintShellVisibility(state);
        setLoadConstraintAcousticVisibility(state);
        setLoadConstraintFESubSysVisibility(state);
    }

    void OperatorModelTreeEvent::setLoadHVACNoiseVisibility(bool state)
    {
        if (_physics == nullptr || _physics->getFITKAcousticsLoadManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractLoad* load : _physics->getFITKAcousticsLoadManager()->
            getLoadByType(Acoustics::FITKAcousticsAbstractLoad::AcousticsLoadType::ImportNoiseHVAC)) {
            if (load == nullptr)continue;
            load->enable(state);
        }
    }

    void OperatorModelTreeEvent::setLoadPowerBeamVisibility(bool state)
    {
        if (_physics == nullptr || _physics->getFITKAcousticsLoadManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractLoad* load : _physics->getFITKAcousticsLoadManager()->
            getLoadByType(Acoustics::FITKAcousticsAbstractLoad::AcousticsLoadType::PowerSEABeam)) {
            if (load == nullptr)continue;
            load->enable(state);
        }
    }

    void OperatorModelTreeEvent::setLoadPowerShellVisibility(bool state)
    {
        if (_physics == nullptr || _physics->getFITKAcousticsLoadManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractLoad* load : _physics->getFITKAcousticsLoadManager()->
            getLoadByType(Acoustics::FITKAcousticsAbstractLoad::AcousticsLoadType::PowerSEAShell)) {
            if (load == nullptr)continue;
            load->enable(state);
        }
    }

    void OperatorModelTreeEvent::setLoadPowerAcousticVisibility(bool state)
    {
        if (_physics == nullptr || _physics->getFITKAcousticsLoadManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractLoad* load : _physics->getFITKAcousticsLoadManager()->
            getLoadByType(Acoustics::FITKAcousticsAbstractLoad::AcousticsLoadType::PowerSEAAcoustic)) {
            if (load == nullptr)continue;
            load->enable(state);
        }
    }

    void OperatorModelTreeEvent::setLoadPowerFESubSysVisibility(bool state)
    {
        if (_physics == nullptr || _physics->getFITKAcousticsLoadManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractLoad* load : _physics->getFITKAcousticsLoadManager()->
            getLoadByType(Acoustics::FITKAcousticsAbstractLoad::AcousticsLoadType::PowerFESubsys)) {
            if (load == nullptr)continue;
            load->enable(state);
        }
    }

    void OperatorModelTreeEvent::setLoadConstraintBeamVisibility(bool state)
    {
        if (_physics == nullptr || _physics->getFITKAcousticsLoadManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractLoad* load : _physics->getFITKAcousticsLoadManager()->
            getLoadByType(Acoustics::FITKAcousticsAbstractLoad::AcousticsLoadType::ConstraintSEABeam)) {
            if (load == nullptr)continue;
            load->enable(state);
        }
    }

    void OperatorModelTreeEvent::setLoadConstraintShellVisibility(bool state)
    {
        if (_physics == nullptr || _physics->getFITKAcousticsLoadManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractLoad* load : _physics->getFITKAcousticsLoadManager()->
            getLoadByType(Acoustics::FITKAcousticsAbstractLoad::AcousticsLoadType::ConstraintSEAShell)) {
            if (load == nullptr)continue;
            load->enable(state);
        }
    }

    void OperatorModelTreeEvent::setLoadConstraintAcousticVisibility(bool state)
    {
        if (_physics == nullptr || _physics->getFITKAcousticsLoadManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractLoad* load : _physics->getFITKAcousticsLoadManager()->
            getLoadByType(Acoustics::FITKAcousticsAbstractLoad::AcousticsLoadType::ConstraintSEAAcoustic)) {
            if (load == nullptr)continue;
            load->enable(state);
        }
    }

    void OperatorModelTreeEvent::setLoadConstraintFESubSysVisibility(bool state)
    {
        if (_physics == nullptr || _physics->getFITKAcousticsLoadManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractLoad* load : _physics->getFITKAcousticsLoadManager()->
            getLoadByType(Acoustics::FITKAcousticsAbstractLoad::AcousticsLoadType::ConstraintFESubsys)) {
            if (load == nullptr)continue;
            load->enable(state);
        }
    }

    void OperatorModelTreeEvent::setLoadMonopoleVisibility(bool state)
    {
        if (_physics == nullptr || _physics->getFITKAcousticsLoadManager() == nullptr)return;
        for (Acoustics::FITKAcousticsAbstractLoad* load : _physics->getFITKAcousticsLoadManager()->
            getLoadByType(Acoustics::FITKAcousticsAbstractLoad::AcousticsLoadType::ExcitationMonopole)) {
            if (load == nullptr)continue;
            load->enable(state);
        }
    }

    QList<Interface::FITKAbsVirtualTopo*> OperatorModelTreeEvent::getAllGeometryVirTopos(Interface::FITKGeoEnum::VTopoShapeType type)
    {
        QList<Interface::FITKAbsVirtualTopo*> virTopoList = {};
        Acoustics::FITKAcousticsGeometryData* geometryData = FITKAPP->getGlobalData()->getGeometryData<Acoustics::FITKAcousticsGeometryData>();
        if (geometryData == nullptr) {
            return virTopoList;
        }

        //获取所有的集合命令
        QList<Interface::FITKAbsGeoCommand*> allGeo = {};
        const int n = geometryData->getDataCount();
        for (int i = 0; i < n; ++i) {
            Interface::FITKAbsGeoCommand* geo = geometryData->getDataByIndex(i);
            if (geo == nullptr) {
                continue;
            }
            allGeo.append(geo);
        }

        //获取虚拓扑
        for (Interface::FITKAbsGeoCommand* geoCom : allGeo) {
            if (geoCom == nullptr) {
                continue;
            }

            Interface::FITKShapeVirtualTopoManager* virTopoManager = geoCom->getShapeVirtualTopoManager(type);
            if (virTopoManager != nullptr) {
                for (int i = 0; i < virTopoManager->getDataCount(); i++) {
                    virTopoList.append(virTopoManager->getDataByIndex(i));
                }
            }
        }
        return virTopoList;
    }
}
